﻿/****************************************************************
Architecture:
Mohammad Ashraful Alam, Microsoft MVP 2007-2010
Portfolio: http://www.ashraful.net
***************************************************************/
namespace DaXDD.DataAccess
{
    //public enum DataAccessProvider { InMemoryDataAccess, SqlClientDataAccess, CacheProvider, OracleClientDataAccess, EntityFrameworkDataAccess }
    public class ProviderHelper
    {
        public static object CreateInstance(string className)
        {
            string configProvider = System.Configuration.ConfigurationSettings.AppSettings["DataAccessProvider"];
            return CreateInstance(configProvider, className);
        }

        public static object CreateInstance(string dataAccessProvider, string className)
        {
            string assName = "DaXDD.DataAccess." + dataAccessProvider;
            string typeName = "DaXDD.DataAccess.Model." + dataAccessProvider + "." + className;

            System.Reflection.AssemblyName asmName = new System.Reflection.AssemblyName(assName);
            System.Reflection.Assembly asm = System.Reflection.Assembly.Load(asmName);

            return asm.CreateInstance(typeName);
        }
    }
}